import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../provider/_providers.dart';


class LoginScreen extends ConsumerWidget  {

  LoginScreen({super.key});


  TextEditingController emailController = TextEditingController();
  TextEditingController passwordController = TextEditingController();

  void login(String email, password) async {}

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    emailController.text = "daijinming";
    passwordController.text = "123456";

    return Scaffold(
      appBar: AppBar(
        title: const Text('用户登录'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(20.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            TextFormField(
              controller: emailController,
              decoration: InputDecoration(hintText: '帐号'),
            ),
            SizedBox(
              height: 20,
            ),
            TextFormField(
              controller: passwordController,
              decoration: InputDecoration(hintText: '密码'),
            ),
            SizedBox(
              height: 40,
            ),
            GestureDetector(
              onTap: () {
                ref.read(userProvider).Login(context,
                    emailController.text.toString()
                    ,
                    passwordController.text.toString());
              },
              child: Container(
                height: 50,
                decoration: BoxDecoration(
                    color: Colors.green,
                    borderRadius: BorderRadius.circular(10)),
                child: Center(
                  child: Text('登录'),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
